#include <dbg.h>
#include <gtest/gtest.h>

using namespace std;

class Solution {
public:
    int maxDepth(TreeNode* root) {
        if (root == nullptr) {
            return 0;
        }
        int leftDepth = maxDepth(root->left);
        int rightDepth = maxDepth(root->right);
        return max(leftDepth, rightDepth) + 1;
    }
};

TEST(MaxDepth, TestCase1) {
    Solution s;

    TreeNode* root = new TreeNode(3);
    root->left = new TreeNode(9);
    root->right = new TreeNode(20);
    root->right->left = new TreeNode(15);
    root->right->right = new TreeNode(7);

    EXPECT_EQ(s.maxDepth(root), 3);
}

TEST(MaxDepth, TestCase2) {
    Solution s;

    TreeNode* root = new TreeNode(1);
    root->right = new TreeNode(2);

    EXPECT_EQ(s.maxDepth(root), 2);
}

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}